The present invention relates generally to processor-based systems, and more particularly to techniques for compressing programs and other information for use in such systems.
A conventional embedded system is typically implemented as a circuit board including a central processing unit (CPU) or other type of processor, a random access memory (RAM), one or more input/output (I/O) devices, and an on-board non-volatile memory. The non-volatile memory is used by the system to store data, programs or other information.
In the case of programs, there are a number of different ways in which corresponding program code may be stored within the non-volatile memory of the system. A first approach is to store the program in a raw binary form, such that the CPU accesses the program directly in the nonvolatile memory. This generally requires that a loading program used by the CPU to access the program have some knowledge of the program stored in the non-volatile memory. A second approach is to store the program as a file containing information that instructs the loading program with regard to issues such as location of the program code in non-volatile memory, where to place the retrieved program code in RAM, how to start up the program, etc. An advantage of the second approach relative to the first is that the second approach eliminates the need for the loading program to have any specific knowledge of the program, i.e., it is a more xe2x80x9cdata drivenxe2x80x9d approach.
In one conventional implementation of the second approach described above, a program is stored in the non-volatile memory as a formatted program file. The loading program retrieves not only the program code, but also information in the file that instructs the loading program as to where to place the retrieved program code in RAM and how to start up the program. This information in the file is also referred to herein as xe2x80x9crelocation data.xe2x80x9d
The above-noted file can be stored in the non-volatile memory in a compressed or an uncompressed form. An advantage of compression is that it saves on the amount of non-volatile memory space needed to store the program. However, compression also has the disadvantage of requiring processor time and memory capacity to execute.
The following example illustrates in more detail the disadvantages associated with conventional program file compression in an embedded system. Assume a file is compressed on a host processing device, such as a personal computer (PC). It is then transferred to the embedded system in its compressed form. At some later point in time, the CPU of the embedded system decompresses the file into a designated memory space xe2x80x98Axe2x80x99 in order to access the relocation data. The relocation data is then read and, based on the relocation data, the program is transferred to memory space xe2x80x98Bxe2x80x99 and executed.
The use of conventional program file compression in an embedded system thus requires two separate memory copy operations, the first to decompress the file in order to allow the CPU to access the relocation data, and the second to perform the specified relocation.
A need therefore exists for an improved compression approach for use in conjunction with embedded systems, which overcomes the above-noted disadvantages of conventional file compression.
The invention provides improved techniques for compressing information for use in an embedded system.
In accordance with one aspect of the invention, a program file or other type of information file for use in an embedded system is partially compressed in a host device and transferred to a nonvolatile memory of the embedded system. The compressed portion of the file in an illustrative embodiment may include non-relocation data such as data sections, text sections, symbol tables, etc. The uncompressed portion in the illustrative embodiment includes relocation data such as section headers or a file header which identify one or more destination locations for corresponding parts of the file in a random access memory of the embedded system.
In accordance with another aspect of the invention, a loading program running on a processor of the embedded system determines a destination location for at least part of the file within the embedded system without decompressing the compressed portion of the file.
Advantageously, the invention eliminates the need for multiple file copy operations in the process of transferring data between non-volatile memory and random access memory in an embedded system.